﻿using RecruitStudents.Client.BLL;
using RecruitStudents.Utility;
using RecruitStudents.Utility.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecruitStudents.Client
{
    public partial class ChooseForm_ExamPlace : BaseForm
    {
        ServiceComm service = new ServiceComm();
        public ChooseForm_ExamPlace()
        {
            InitializeComponent();
            BindExamPlace();
        }

        private void BindExamPlace()
        {
            using (DataTable dt = service.GetExamPlaceTableALL_CS())
            {
                listExamPlace.DisplayMember = "ExamPlaceName";
                listExamPlace.ValueMember = "ExamPlaceNO";
                listExamPlace.DataSource = dt;
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnEnter_Click(object sender, EventArgs e)
        {
            if (listExamPlace.SelectedIndex < 0)
            {
                DevHelper.ShowErrorMessageBox("请先选择考点!");
                return;
            }
            string ExamPlaceID = string.Empty;
            string ExamPlaceName = string.Empty;
            string SpecialityKindsNO = string.Empty;
            string SpecialityKindsName = string.Empty;
            string ExamLevel = string.Empty;
            string ExamLevelName = string.Empty;
            if (listExamPlace.SelectedItem != null)
            {
                DataRowView drExamPlace = (DataRowView)listExamPlace.SelectedItem;
                ExamPlaceID = drExamPlace.Row.ItemArray[0].ToSafeString();
                ExamPlaceName = drExamPlace.Row.ItemArray[1].ToSafeString();
            }
            SessionerHelper.SpecialityKinds = SpecialityKindsName;
            SessionerHelper.SpecialityKindsNO = SpecialityKindsNO;
            SessionerHelper.ExamLevel = ExamLevel;
            SessionerHelper.ExamLevelName = ExamLevelName;
            SessionerHelper.ExamPlaceID = ExamPlaceID;
            SessionerHelper.ExamPlaceName = ExamPlaceName;
            SessionerHelper.ExamRoomID = SessionerHelper.ExamRoomName = string.Empty;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
